﻿using EYangFramework.Business.SystemManager.Interfaces;
using EYangFramework.Domain.Entitys.ValueObjects;
using EYangFramework.Domain.Repositorys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EYangFramework.Business.SystemManager.Implementation
{
    public class BLLNavigation : IBLLNavigation
    {
        private IRepository<Navigation> RepositoryNavigation;
        public BLLNavigation(IRepository<Navigation> repositoryNavigation)
        {
            RepositoryNavigation = repositoryNavigation;
        }

        public bool DeletSelectedNavigation(Guid id)
        {
            RepositoryNavigation.Delete(t => t.ID == id || t.PREVIEWNAVIGATION.ID == id);//当删除模块的时候,其所有的子节点同时被删除
            return true;
        }

        public void Dispose()
        {
            (RepositoryNavigation as Repository<Navigation>).DbContext.Dispose();
        }

        public List<Navigation> GetAllList()
        {
            return RepositoryNavigation.GetAllList();
        }

        public Navigation GetBusinessById(Guid id)
        {
            return RepositoryNavigation.Get(id);
        }

        public bool InsertNavigation(Navigation navigation)
        {
            RepositoryNavigation.Insert(navigation);
            return true;
        }

        public bool UpdateSelectedNavigation(Navigation navigation)
        {
            RepositoryNavigation.Update(navigation);
            return true;
        }
    }
}
